home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / tutorials / OGLT / Examples / TerrainFollowing / src.hansen / culling.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-11  |  4.1 KB  |  112 lines

  1.  /**************************************************************************
  2.   *                                                                        *
  3.   *               Copyright (C) 1996, Silicon Graphics, Inc.               *
  4.   *                          All Rights Reserved.                          *
  5.   *                                                                        *
  6.   *  The files in this subtree  contain  UNPUBLISHED  PROPRIETARY  SOURCE  *
  7.   *  CODE of Silicon Graphics, Inc.;  the  contents  of  these  files may  *
  8.   *  not be disclosed to third  parties,  copied  or  duplicated  in  any  *
  9.   *  form, in whole or in part,  without  the  prior  written  permission  * 
  10.   *  of  Silicon Graphics, Inc.                                            *
  11.   *                                                                        *
  12.   *  RESTRICTED RIGHTS LEGEND:                                             *
  13.   *  Use,  duplication  or  disclosure  by  the  Government is subject to  *
  14.   *  restrictions as set forth in subdivision (c)(1)(ii) of the Rights in  *
  15.   *  Technical Data and Computer Software clause at  DFARS  252.227-7013,  *
  16.   *  and/or in similar or successor  clauses in the FAR,  DOD or NASA FAR  *
  17.   *  Supplement.  Unpublished - rights reserved  under the Copyright Laws  *
  18.   *  of the United States.                                                 *
  19.   *                                                                        *
  20.   *  THIS SOFTWARE IS  PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,  *
  21.   *  EXPRESS,  IMPLIED OR  OTHERWISE,  INCLUDING  WITHOUT LIMITATION, ANY  *
  22.   *  WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.      *
  23.   *                                                                        *
  24.   *  IN  NO  EVENT  SHALL  SILICON  GRAPHICS  BE  LIABLE FOR ANY SPECIAL,  *
  25.   *  INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF  ANY  KIND,  OR ANY  *
  26.   *  DAMAGES WHATSOEVER RESULTING FROM LOSS  OF  USE,  DATA  OR  PROFITS,  *
  27.   *  WHETHER OR NOT ADVISED OF  THE  POSSIBILITY  OF  DAMAGE,  AND ON ANY  *
  28.   *  THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR  *
  29.   *  PERFORMANCE OF THIS SOFTWARE.                                         *
  30.   **************************************************************************/
  31.  
  32. /*
  33.     Author : Paul Hansen          & Patrick Bouchaud
  34.              hansen@engr.sgi.com    galaad@neu.sgi.com
  35. */
  36.  
  37.  
  38. /*---------------------------------------------------------------------------*/
  39. /*    data structures
  40. /*---------------------------------------------------------------------------*/
  41. typedef struct _vertex
  42. {
  43.     GLdouble    x, y, z;
  44.     int            in;
  45.     struct        _vertex *next, *last;
  46. }
  47. Vertex;
  48.  
  49. #define    CULLED_IN        0
  50. #define    CULLED_OUT        1
  51. #define    CLIPPED_START    2
  52. #define    CLIPPED_END        3
  53. typedef struct _segment
  54. {
  55.     Vertex        *start, *end;
  56.     int            state;
  57.     struct        _segment *next, *last;
  58. }
  59. Segment;
  60.  
  61. typedef struct _edge
  62. {
  63.     Segment        *segment;
  64.     int            inverted;
  65.     struct        _edge *next, *last;
  66. }
  67. Edge;
  68.  
  69. typedef struct _face
  70. {
  71.     int            numEdge;
  72.     Edge        *firstEdge;    /* ring-buffer */
  73.     GLdouble    equation[4];
  74.     struct        _face *next, *last;
  75. }
  76. Face;
  77.  
  78. typedef struct _volume
  79. {
  80.     int            numVertex;
  81.     Vertex        *firstVertex, *lastVertex;
  82.  
  83.     int            numSegment, numNewSegment;
  84.     Segment        *firstNewSegment, *firstSegment, *lastSegment;
  85.  
  86.     int            numFace;
  87.     Face        *firstFace, *lastFace;
  88.  
  89.     struct _volume *next;
  90. }
  91. Volume;
  92.  
  93. /*---------------------------------------------------------------------------*/
  94. /*    data
  95. /*---------------------------------------------------------------------------*/
  96.  
  97. static GLdouble xdim, zdim;
  98. static Volume *pyramid = NULL;
  99.  
  100. static Segment *newSegment( Volume *, Vertex *, Vertex * );
  101. static Face *newFace( int, GLdouble * );
  102. static void deleteVolume( Volume * );
  103. static Volume *newFrustumPyramid();
  104. static Vertex *ClipLine3D( Vertex *, Vertex *, GLdouble * );
  105. static void ClipVolume( Volume *, GLdouble * );
  106. static void BBoxClip( Volume *, float, float, float, float, float, float );
  107. static int getMinMaxLat( Volume *, float *, float * );
  108. static int getMinMaxLon( Volume *, float, float *, float * );
  109.  
  110. #define    equate(v,eq) (eq[0]*v->x + eq[1]*v->y + eq[2]*v->z + eq[3])
  111.  
  112.